﻿using NUnit.Framework;
using Pantry.Commons;
using Pantry.DataAccess;
using Pantry.Entity;


namespace Pantry.UnitTest
{
    [TestFixture]
    class TestAccountDao
    {
        private AccountDao _accountDao;
        private readonly User _user;

        public TestAccountDao(User user)
        {
            _user = user;
        }

        private const string ConnectionString = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
        [SetUp]
        public void Init()
        {
            _accountDao = new AccountDao(ConnectionString);
            _accountDao = new AccountDao();
        }

        [Test, Sequential]
        public void LogOn(
            [Values("admin")] string username,
            [Values("123")] string password,
            [Values(1)] int expectedResult
            )
        {
            string encrypted = CryptographyHelper.EncryptionMD5(password);
            int result = _accountDao.LogOn(_user);
            Assert.AreEqual(result, expectedResult);
        }

        [Test, Sequential]
        public void ForgotPassword(
            [Values("duongnt8", "abc")] string username,
            [Values("duongnt8@fsoft.com.vn", "abc@yahoo.com")] string email,
            [Values(1,0)] int expectedResult
            )
        {
            int result = _accountDao.ChangePassword(_user);
            Assert.AreEqual(result,expectedResult);
        }
    }
}
